package com.hamizhong.iflowers.common.listener;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import com.hamizhong.iflowers.common.logger.MyLogger;
import com.hamizhong.iflowers.common.logger.MyLoggerFactory;

public class IFlowersSessionContextListener implements HttpSessionListener {

	Logger logger = LogManager.getLogger(this.getClass());

	private int SessionCnt = 0;
	public void sessionCreated(HttpSessionEvent sessionEvent) {
		synchronized (this) {
			++SessionCnt;
		}
		logger.info("Current session count : "+SessionCnt);
	}

	public void sessionDestroyed(HttpSessionEvent sessionEvent) {
		synchronized (this) {
			--SessionCnt;
		}
		logger.info("Current session count : "+SessionCnt);
	}

}
